package com.dizang.sharding.common.repository.impl;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dizang.sharding.common.repository.BaseRepository;

/**
 * 
 * @author kelvin
 *
 * @param <T>
 */
public abstract class BaseRepositoryImpl<T> implements BaseRepository<T> {

    /**
     * 每个实现类都需要BaseDao
     * @return BaseMapper
     */
	protected abstract BaseMapper<T> getRepository();
	
	@Override
	public int insert(T entity) {
		return getRepository().insert(entity);
	}

	@Override
	public int deleteById(Serializable id) {
		return this.getRepository().deleteById(id);
	}

	@Override
	public int deleteByMap(Map<String, Object> columnMap) {
		return this.getRepository().deleteByMap(columnMap);
	}

	@Override
	public int delete(Wrapper<T> wrapper) {
		return this.getRepository().delete(wrapper);
	}

	@Override
	public int deleteBatchIds(Collection<? extends Serializable> idList) {
		return this.getRepository().deleteBatchIds(idList);
	}

	@Override
	public int updateById(T entity) {
		return this.getRepository().updateById(entity);
	}


	@Override
	public int update(T entity, Wrapper<T> wrapper) {
		return this.getRepository().update(entity, wrapper);
	}


	@Override
	public T selectById(Serializable id) {
		return this.getRepository().selectById(id);
	}

	@Override
	public List<T> selectBatchIds(Collection<? extends Serializable> idList) {
		return this.getRepository().selectBatchIds(idList);
	}

	@Override
	public List<T> selectByMap(Map<String, Object> columnMap) {
		return this.getRepository().selectByMap(columnMap);
	}

	@Override
	public Integer selectCount(Wrapper<T> wrapper) {
		return this.getRepository().selectCount(wrapper);
	}

	@Override
	public List<T> selectList(Wrapper<T> wrapper) {
		return this.getRepository().selectList(wrapper);
	}

	@Override
	public List<Map<String, Object>> selectMaps(Wrapper<T> wrapper) {
		return this.getRepository().selectMaps(wrapper);
	}

	@Override
	public List<Object> selectObjs(Wrapper<T> wrapper) {
		return this.getRepository().selectObjs(wrapper);
	}

	@Override
	public T selectOne(Wrapper<T> queryWrapper) {
		return this.getRepository().selectOne(queryWrapper);
	}

	@Override
	public IPage<T> selectPage(IPage<T> page, Wrapper<T> queryWrapper) {
		return this.getRepository().selectPage(page, queryWrapper);
	}
	
	@Override
	public IPage<Map<String, Object>> selectMapsPage(IPage<T> page, Wrapper<T> queryWrapper) {
		return this.getRepository().selectMapsPage(page, queryWrapper);
	}

}
